#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

void arr1(char* arr, int sz, int k)
{
	int a = k % sz;
	if (a == 0 || arr == NULL)
		return;
	char* qqq = malloc(sz);
	int i = 0;
	for (; i < a; i++)
	{
		qqq[i] = arr[i];
	}
	int j = i;
	int c = 0;
	for (; j < sz; j++)
	{
		arr[c++] = arr[j];
	}
	for (j = 0; j < i; j++)
	{
		arr[c++] = qqq[j];
	}
	free(qqq);
}
int main()
{
	char arr[100] = { 0 };
	int k = 0;
	scanf("%s %d", arr, &k);
	int sz = strlen(arr);
	arr1(arr, sz, k);
	printf("%s", arr);
	return 0;
}
